package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduAppointSchool.EduAppointSchoolKeyVO;
import com.jwsoft.manager.common.vo.eduAppointSchool.EduAppointSchoolQueryVO;
import com.jwsoft.manager.common.vo.eduAppointSchool.EduAppointSchoolVO;
import com.jwsoft.manager.common.vo.eduSchool.EduSchoolQueryVO;
import com.jwsoft.manager.common.vo.eduSchool.EduSchoolVO;
import com.jwsoft.manager.core.integration.EduAppointSchoolIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 城区E学校维护表网关
 *
 * @author hhj
 * @since 2022-12-19
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "城区E学校维护表", description = "城区E学校维护表")
public class EduAppointSchoolController {

    @Autowired
    public EduAppointSchoolIntegration eduAppointSchoolIntegration;

    @PostMapping(value = "/eduAppointSchool0100", produces = "application/json;charset=UTF-8")
    @Operation(summary = "获取小学学校", description = "获取小学学校")
    public AppResponse<PageInfo<EduSchoolVO>> getPrimarySchoolList(
            @RequestBody @Validated EduSchoolQueryVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.getPrimarySchoolList(vo));
    }

    @PostMapping(value = "/eduAppointSchool0101", produces = "application/json;charset=UTF-8")
    @Operation(summary = "获取初中学校", description = "获取初中学校")
    public AppResponse<PageInfo<EduSchoolVO>> getJuniorSchoolList(
            @RequestBody @Validated EduSchoolQueryVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.getJuniorSchoolList(vo));
    }

    @Operation(summary = "城区E学校维护表分页查询",description = "城区E学校维护表分页查询")
    @PostMapping(value = "/eduAppointSchool0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduAppointSchoolVO>> getList(@RequestBody @Validated EduAppointSchoolQueryVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.getList(vo));
    }

    @Operation(summary = "城区E学校维护表根据主键查询详情",description = "城区E学校维护表根据主键查询详情")
    @PostMapping(value = "/eduAppointSchool0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAppointSchoolVO> getById(@RequestBody @Validated EduAppointSchoolKeyVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区E学校维护表新增",description = "城区E学校维护表新增")
    @PostMapping(value = "/eduAppointSchool0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAppointSchoolVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduAppointSchoolVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区E学校维护表修改",description = "城区E学校维护表修改")
    @PostMapping(value = "/eduAppointSchool0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAppointSchoolVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduAppointSchoolVO vo) {
        return AppResponse.successData(eduAppointSchoolIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区E学校维护表删除",description = "城区E学校维护表删除")
    @PostMapping(value = "/eduAppointSchool0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduAppointSchoolKeyVO vo) {
        eduAppointSchoolIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
